
<style>
    #device_Update_div label {
        width: 150px;
        background-color: #dddddd;
    }

    #device_Update_div div.layui-form-item {
        margin-bottom: 5px;
    }

    #device_Update_div fieldset {
        padding-bottom: 2px;
    }

    #device_Update_div div.layui-tab-content {
        height: 401px;
    }

    .selectUp .layui-form-select dl {
        top: auto;
        bottom: 36px;
    }

</style>
<div class="layui-form layuimini-form  layui-form-pane" id="device_Update_div" lay-filter="device_Update_div_filter">
    <div class="layui-panel" style="height:450px;">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this"> 系统设置</li>
                <li> 门禁设置</li>
                <li> 人脸识别</li>
                <li> 网络参数</li>
                <li> 其他</li>
            </ul>

            <div class="layui-tab-content">
                <!-- 系统设置 -->
                <div class="layui-tab-item layui-show" id="device_Update_Page1">


                    <fieldset class="table-search-fieldset">
                        <legend> 设备身份</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 设备SN</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="16" lay-verify="required" name="deviceID" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 设备名称</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="30" lay-verify="required" name="deviceName" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 版本号</label>
                                    <div class="layui-input-inline ">
                                        <label class="layui-form-label" style="background-color: #ffffff; width: 190px; "> ver 0202</label>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 制造商</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="40" name="parameterManufacturer" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 网址</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="40" name="parameterWebsite" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 生产日期</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="20" name="parameterProductionDate" lay-verify="required" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 公司名称</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="30" name="parameterCompanyName" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 菜单密码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="8" name="parameterLoginPassword" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 补光灯</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 开关</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterLightSwitch" lay-skin="switch" lay-text="开启|关闭" value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 灯亮灭时间</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="65535" min="0" name="parameterLightTimeout" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 自动补光</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterLightActive" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 声音及文字</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 音量</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="84" min="1" required maxlength="2" name="parameterVolume" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 亮度</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="10" min="1" required maxlength="2" name="parameterBrightness" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 语言</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterLanguageChoose" required lay-verify="">
                                            <option value="0" selected>中文</option>
                                            <option value="1">英文</option>
                                            <option value="2">繁体</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 语音播报</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterVoiceMode" required lay-verify="">
                                            <option value="0">不播报</option>
                                            <option value="1">播放名字</option>
                                            <option value="2">播放问候语</option>
                                            <option value="3" selected>播放名字和问候语</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 问候语</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterGrettings" required lay-verify="">
                                            <option value="0" selected>请通行</option>
                                            <option value="1">欢迎光临</option>
                                            <option value="2">时间问候语</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 陌生人语音</label>
                                    <div class="layui-input-inline selectUp">
                                        <select name="parameterStrangerVoice" required lay-verify="">
                                            <option value="0">不播报</option>
                                            <option value="1">播报假体</option>
                                            <option value="2" selected>播报陌生人</option>
                                            <option value="3">播报假体和陌生人</option>
                                        </select>

                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>


                </div>
                <!-- 门禁设置 -->
                <div class="layui-tab-item" id="device_Update_Page2">

                    <fieldset class="table-search-fieldset">
                        <legend> 鉴权参数</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 出入类型</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="parameterAccessType" value="0" title="入门" checked>
                                        <input type="radio" name="parameterAccessType" value="1" title="出门" >
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 免验证开门</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterLaissezSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 识别间隔（秒）</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="65535" min="0" name="parameterRecgInterval" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">保存重复记录</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterIntervalRecoSwitch" lay-skin="switch" lay-text="保存|丢弃" unchecked value="1">
                                    </div>
                                </div>
                            </div>

                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 输入输出</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> WG格式</label>
                                    <div id="divparameterWgFormat" class="layui-input-inline" style="padding-right: 1px; margin-right: 1px;">
                                        <input type="radio" name="parameterWgFormat" value="26" title="26">
                                        <input type="radio" name="parameterWgFormat" value="34" title="34" checked>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 开门保持(秒)</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="65535" min="0" name="parameterKeepOpenDoor" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 门磁类型</label>
                                    <div class="layui-input-inline">
                                        <select name="parameterDoorSensor" required lay-verify="">
                                            <option value="0" selected>常闭</option>
                                            <option value="1">常开</option>
                                            <option value="2">无</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 报警</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 门磁报警</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterDoorAlarmSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 开门超时(秒)</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="255" min="5" name="parameterDoorSensorDelay" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>

                </div>

                <!-- 人脸识别 -->
                <div class="layui-tab-item" id="device_Update_Page3">
                    <fieldset class="table-search-fieldset">
                        <legend> 人脸检测</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label"> 识别间隔（秒）</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="99" min="1" name="parameterFaceThreshold" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 识别距离(cm)</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="150" min="50" name="parameterDistance" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 活体检测</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterPreview" lay-skin="switch" lay-text="启用|禁用" checked value="1">
                                    </div>
                                </div>

                            </div>

                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 口罩检测</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">口罩检测</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterMask" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 口罩阈值</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="99" min="1" name="parameterMaskThreshold" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 体温检测</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 体温检测</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterTempPattern" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 温度补偿</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="1000" min="0" name="parameterCompensate" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 比对阈值</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="100   " min="30" name="parameterTempThresholdMax" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 华氏度</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterFahrenheitSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 海曼模组 DBHC</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="400" min="200" name="parameterBdhc" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 海曼模组 DBLC</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="400" min="200" name="parameterBdlc" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 中心点坐标</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="4" name="parameterCent" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                </div>
                <!-- 网络参数 -->
                <div class="layui-tab-item" id="device_Update_Page4">
                    <fieldset class="table-search-fieldset">
                        <legend> 服务器参数</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label"> 服务器地址</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="100" name="parameterCloudserverAddress" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 保活包间隔(秒)</label>
                                    <div class="layui-input-inline">
                                        <input type="number" max="7200" min="5" name="parameterPolling" autocomplete="off" class="layui-input">
                                    </div>
                                </div>

                            </div>

                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 有线网络</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">开关</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterNetworkSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> DHCP</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterNetworkIpActive" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> DNS</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="15" name="parameterNetworkDns" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">IP</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="15" name="parameterNetworkIpUrl" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 子网掩码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="15" name="parameterNetworkSubnetMask" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 网关</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="15" name="parameterNetworkGteway" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 无线网络</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 开关</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterWifiSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 账号</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="30" name="parameterNetworkGteway" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 密码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="30" name="parameterNetworkGteway" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <fieldset class="table-search-fieldset">
                        <legend> 热点</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 开关</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterHotspotSwitch" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 账号</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="30" name="parameterHotspotName" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 密码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" maxlength="30" name="parameterHotspotPassword" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                </div>

                <!-- 其他 -->
                <div class="layui-tab-item" id="device_Update_Page5">
                    <fieldset class="table-search-fieldset">
                        <legend> 记录存储</legend>
                        <div style="margin: 3px 3px 3px 3px">
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label"> 存储陌生人记录</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterSaveExternalvisitors" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label"> 保存现场图片</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="parameterSavePicture" lay-skin="switch" lay-text="启用|禁用" unchecked value="1">
                                    </div>
                                </div>

                            </div>

                        </div>

                    </fieldset>
                </div>
            </div>

        </div>
    </div>
    <div class="layui-panel" style="text-align: center;" id="device_update_button_div">
        <style>
            #device_update_button_div button {
                width: 150px;
            }
        </style>
        <div style="margin: 5px 5px 5px 5px">
            <!-- 按钮 -->
            <div class="layui-form-item">
                <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-normal"
                            lay-submit lay-filter="data-save-btn">
                        <i class="layui-icon"></i> 保存
                    </button>
                </div>
                <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-danger"
                            id="data-cancel-btn">
                        <i class="layui-icon"></i> 取消
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use(['form', 'laydate', 'element', 'faceAPI'], function () {
        var element = layui.element;
        var form = layui.form;
        var laydate = layui.laydate, $ = layui.$;;
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        var faceAPI = layui.faceAPI;

        if (faceAPI.hasOwnProperty['DevicePageUpdate'] == false) {
            layer.close(parentIndex);
            return;
        }

        if (faceAPI.DevicePageUpdate == null) {
            layer.close(parentIndex);
            return;
        }
        //执行一个laydate实例
        laydate.render({
            elem: '[name="parameterProductionDate"]', //指定元素
            type: 'datetime'
        });

        //开始绑定字段值
        var d = faceAPI.DevicePageUpdate;
        //console.log(d);
        form.val("device_Update_div_filter", d);

        //监听测试
        $('#data-cancel-btn').on('click', function () {
            layer.close(parentIndex);
        });


        //监听提交
        form.on('submit(data-save-btn)', function (data) {
            var postdata = data.field;
            //console.log(postdata);
            postdata.id = d.id;
            postdata.parameterSerialNum = postdata.deviceID;
            faceAPI.Ajax({
                type: 'Post',
                data: postdata,
                url: '/api/FaceDevice/Update',
                success: function (result) {
                    if (result.result == false) {
                        layer.alert(result.error, { icon: 2 });
                    }
                    else {
                        layer.close(parentIndex);
                    }

                }
            });
            return false;
        });
    });
</script>
